import {
  URL
} from './config.js';
export const request = (options) => { //请求网络数据函数封装
  let ajaxNum = 0
  wx.showLoading({
    title: '加载中',
    mask: true,
  });
  return new Promise((resolve, reject) => {
    wx.request({
      ...options,
      url: URL + options.url,
      header:{
        'content-type': 'application/x-www-form-urlencoded'
      },
      success: (res) => {
        ajaxNum++
        resolve(res.data)
      },
      fail: reject,
      complete: () => {
        ajaxNum--
        ajaxNum == 0 ? wx.hideLoading() : ''
      }
    })
  })
}